package com.itheima.service.Impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.Mapper.EmpLogMapper;
import com.itheima.pojo.*;
import com.itheima.service.EmpLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class EmpLogServiceImpl implements EmpLogService {

    @Autowired
    private EmpLogMapper empLogMapper;

    @Transactional
    @Override
    public void insertLog(EmpLog empLog) {
        empLogMapper.insert(empLog);
    }




    @Override
    public PageResult page(EmpQueryParam empQueryParam) {

        //1.设置PageHelper分页参数
        PageHelper.startPage(empQueryParam.getPage(),empQueryParam.getPageSize());

        //2.执行查询
        List<OperateLog> empLogList = empLogMapper.page(empQueryParam);

        //3.封装分页结果
        Page<OperateLog> p = (Page<OperateLog>)empLogList;
        return new PageResult(p.getTotal(), p.getResult());




    }
}